home *** CD-ROM | disk | FTP | other *** search
- <!--- NAVIGATION BUTTONS (view page) --->
-
- <CFIF ParameterExists( Form.btnView_Next )
- or ParameterExists( Form.btnView_Previous )
- or ParameterExists( Form.btnView_First )
- or ParameterExists( Form.btnView_Last )
- >
-
- <!--- retrieve DNs for all viewed records --->
- <CFLDAP NAME="GetDNs"
- SERVER="$${ServerName}"
- PORT="$${ServerPort}"
- USERNAME="$${Username}"
- PASSWORD="$${Password}"
- ACTION="query"
- START="$${Root}"
- SCOPE="oneLevel"
- ATTRIBUTES="dn"
- TIMEOUT="$${Timeout}"
- >
-
-
- <!--- default values --->
- <CFSET New_dn = Form.dn>
- <CFSET RecordFound = "no">
-
- <!--- scroll thru all entries and find the one we are looking for --->
- <CFOUTPUT query="GetDNs">
- <CFIF not RecordFound>
-
- <CFSET Current_dn = GetDNs.dn>
-
- <!--- what navigation button was used? --->
-
- <CFIF ParameterExists( Form.btnView_First )
- and CurrentRow is 1
- >
- <CFSET New_dn = Current_dn>
- <CFSET RecordFound = "yes">
-
- <CFELSEIF ParameterExists( Form.btnView_Last )
- and CurrentRow is RecordCount
- >
- <CFSET New_dn = Current_dn>
- <CFSET RecordFound = "yes">
-
- <CFELSEIF ParameterExists( Form.btnView_Previous )>
- <CFIF Current_dn is Form.dn>
- <CFSET RecordFound = "yes">
- <CFELSE>
- <CFSET New_dn = Current_dn>
- </CFIF>
-
- <CFELSEIF ParameterExists( Form.btnView_Next )>
- <CFIF New_dn is Form.dn
- and CurrentRow is not 1
- >
- <CFSET RecordFound = "yes">
- </CFIF>
- <CFSET New_dn = Current_dn>
-
- </CFIF>
-
- </CFIF>
- </CFOUTPUT>
-
- <!--- return the view page displaying the required entry (first, previous, next or last) --->
- <CFLOCATION url="$${SafeApplicationName}_LdapView.cfm?dn=#URLEncodedFormat(New_dn)#">
-
-
-
- <!--- EDIT BUTTON (view page) --->
-
- <CFELSEIF ParameterExists( btnView_Edit )>
-
- <!--- redirect to edit page with passing the DN attribute --->
- <CFLOCATION url="$${SafeApplicationName}_LdapEdit.cfm?dn=#URLEncodedFormat(Form.dn)#">
-
-
-
-
- <!--- ADD BUTTON (view page) --->
-
- <CFELSEIF ParameterExists( btnView_Add )>
-
- <!--- redirect to edit page without passing the DN attribute --->
- <CFLOCATION url="$${SafeApplicationName}_LdapEdit.cfm">
-
-
-
- <!--- DELETE BUTTON (view page) --->
-
- <CFELSEIF ParameterExists( btnView_Delete )>
-
- <!--- delete the selected entry --->
- <CFLDAP SERVER="$${ServerName}"
- PORT="$${ServerPort}"
- USERNAME="$${Username}"
- PASSWORD="$${Password}"
- ACTION="delete"
- DN="#Form.dn#"
- TIMEOUT="$${Timeout}"
- >
-
- <!--- redirect to view page without passing the DN attribute --->
- <CFLOCATION url="$${SafeApplicationName}_LdapView.cfm">
-
-
-
- <!--- CANCEL BUTTON (edit page) --->
-
- <CFELSEIF ParameterExists( btnEdit_Cancel )>
-
- <CFIF ParameterExists(Form.dn)>
- <!--- if entry has been edited, return to the view page and display it --->
- <CFLOCATION url="$${SafeApplicationName}_LdapView.cfm?dn=#URLEncodedFormat(Form.dn)#">
- <CFELSE>
- <!--- else just return to the view page --->
- <CFLOCATION url="$${SafeApplicationName}_LdapView.cfm">
- </CFIF>
-
-
-
- <!--- OK BUTTON (edit page) --->
-
- <CFELSEIF ParameterExists( btnEdit_OK )>
-
-
- <!--- default action --->
- <CFSET Action = "ADD">
-
- <!--- is this a new entry? --->
- <CFIF not ParameterExists(Form.dn)>
-
- <CFSET EntryDN = "$${FirstInDN}=#Form.$${FirstInDN}#, $${Root}">
-
- <!--- check whether the record with such dn already exists --->
- <CFLDAP NAME="GetDNs"
- SERVER="$${ServerName}"
- PORT="$${ServerPort}"
- USERNAME="$${Username}"
- PASSWORD="$${Password}"
- ACTION="query"
- START="$${Root}"
- SCOPE="oneLevel"
- ATTRIBUTES="dn"
- TIMEOUT="20"
- >
-
- <!--- check whether such record already exists --->
- <CFLOOP query="GetDNs">
- <CFIF GetDNs.dn is EntryDN>
-
- <CFSET Action = "MODIFY">
- <CFBREAK>
-
- </CFIF>
- </CFLOOP>
-
- <!--- ... else the entry already exists --->
- <CFELSE>
-
- <CFSET EntryDN = #Form.dn#>
- <CFSET Action = "MODIFY">
-
- </CFIF>
-
-
- <!--- if entry already exists retrieve all its attributes --->
- <CFIF Action is "MODIFY">
- <CFLDAP NAME="CheckRecord"
- SERVER="205.181.21.78"
- PORT="389"
- USERNAME=""
- PASSWORD=""
- ACTION="query"
- START="#EntryDN#"
- SCOPE="base"
- ATTRIBUTES="#Form.Attributes#"
- TIMEOUT="20"
- MAXROWS="1"
- >
- </CFIF>
-
-
- <!--- generate the attribute list for the ADD/MODIFY operation --->
- <CFSET AttrValueList = ''>
- <CFLOOP index="AttrName" list="#Form.Attributes#">
-
- <CFSET AttrValue = Evaluate('Form.#AttrName#')>
- <CFSET AttrValue = Replace( AttrValue, ";", ";;", "ALL" )>
- <CFSET AddToList = "no">
-
- <!--- if adding entry, use only non-empty attributes --->
- <CFIF Action is "ADD"
- and Trim(AttrValue) is not ''
- >
- <CFSET AddToList = "yes">
-
- <!--- ... else if modifying entry, use only attributes are being changed --->
- <CFELSEIF Action is "MODIFY">
- <CFIF Trim(AttrValue) is not Trim(Evaluate('CheckRecord.#AttrName#'))>
- <CFSET AddToList = "yes">
- </CFIF>
-
- </CFIF>
-
- <!--- add to list of attributes and their values --->
- <CFIF AddToList>
- <CFSET AttrValueList = ListAppend( AttrValueList, AttrName & '=' & AttrValue & ',', ';' )>
- </CFIF>
-
- </CFLOOP>
-
- <!--- add the objectClass attribute --->
- <CFIF Action is 'ADD'>
- <CFSET AttrValueList = ListAppend( AttrValueList, 'objectClass=$${ObjectClass}', ';' )>
- </CFIF>
-
-
- <!--- add/modify the entry --->
- <CFIF #AttrValueList# is not ''>
- <CFLDAP SERVER="$${ServerName}"
- PORT="$${ServerPort}"
- USERNAME="$${Username}"
- PASSWORD="$${Password}"
- ACTION="#Action#"
- DN="#EntryDN#"
- ATTRIBUTES="#AttrValueList#"
- TIMEOUT="20"
- >
- </CFIF>
-
- <!--- view added/modified entry --->
- <CFLOCATION url="$${SafeApplicationName}_LdapView.cfm?dn=#URLEncodedFormat(EntryDN)#">
-
- </CFIF>
-
-
-
-